<template>
  <div>
    <el-card shadow="always" :body-style="{ padding: '20px' }">
      <CategorySelector :disabled="showState!==1"></CategorySelector>
    </el-card>

    <el-card shadow="always" :body-style="{ padding: '20px' }" style="margin-top: 20px;">
      <!-- Spu列表 -->
      <SpuList v-if="showState === 1" @changeState="changeState"></SpuList>

      <!-- Spu表单 -->
      <SpuForm v-else-if="showState === 2" :spu="spu" @changeState="changeState"></SpuForm>

      <!-- Sku表单 -->
      <SkuForm v-else :spu="spu" @changeState="changeState"></SkuForm>
    </el-card>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
  name: 'Spu'
})
</script>
<script lang="ts" setup>
import SkuForm from './components/SkuForm/index.vue'
import SpuForm from './components/SpuForm/index.vue'
import SpuList from './components/SpuList/index.vue'
import { ref } from 'vue';
import type {SpuData} from '@/api/spu'
const showState = ref(1)
const spu=ref<SpuData>({
  spuName:'',
  description:'',
  category3Id:'',
  tmId:'',
  spuSaleAttrList:[],
  spuImageList:[]
})
const changeState=(num:number,row:SpuData)=>{
  showState.value=num
  if(row){
    spu.value=row
  }else{
    spu.value={
      spuName:'',
      description:'',
      category3Id:'',
      tmId:'',
      spuSaleAttrList:[],
      spuImageList:[]
    }
  }
}
</script>

<style lang="less" scoped></style>
